import React from 'react'
import {Redirect, Route} from "react-router-dom"


export default function PrivateRoute({component: Component, ...rest}) {

  //useSelector((state) => state.user.isLogin)
  const initState = JSON.parse(sessionStorage.getItem('initState'))
  const isLogin =  initState ? true : false
  return (
    <Route {...rest} render={(props) => {
      return isLogin ? <Component {...props} /> : <Redirect to={{//路由指向
        pathname: "/login",
        state: {redirect: props.location}
      }}></Redirect>
    }}></Route>
  )
}
